package designpattern

const (
	Traffic_Train  = "Train"
	Traffic_Trip   = "Trip"
	Traffic_Plane  = "Plane"
	Traffic_Unknow = "Unknow"
)

type Traffic interface {
	Travel() string
}

type Train struct {
}

func (t Train) Travel() string {
	println("Travel by train")
	return Traffic_Train
}

type Trip struct {
}

func (trip Trip) Travel() string {
	println("Travel by trip")
	return Traffic_Trip
}

type Plane struct {
}

func (p Plane) Travel() string {
	println("Travel by plane")
	return Traffic_Plane
}

type Unknow struct {
}

func (u Unknow) Travel() string {
	println("Unknow traffic tool")
	return Traffic_Unknow
}

func NewTraffic(trafficType string) Traffic {
	switch trafficType {
	case Traffic_Train:
		return &Train{}
	case Traffic_Trip:
		return &Trip{}
	case Traffic_Plane:
		return &Plane{}
	default:
		return &Unknow{}
	}
}
